<?php

abstract class nRoute {
	const OPTION_CALLBACK = 'callback';
	protected $options;

	public function __construct($options = array()) {
		$this->options = (array) $options;
	}

	public function getOption($key, $default = null) {
		return array_key_exists($key, $this->options) ? $this->options[$key] : $default;
	}

	abstract public function match($url);

	abstract public function url($params = array());

	public function call($params) {
		$callback = $this->getOption(self::OPTION_CALLBACK);
		if (is_callable($callback))
			call_user_func($callback, $params);
	}
}